/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package soatonline.gui;

import java.awt.Color;
import java.awt.MouseInfo;
import java.awt.Point;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import soatonline.VO.DatePicker;
import soatonline.VO.Fondo;
import soatonline.VO.TestConnection;

/**
 *
 * @author Oskar
 */
public class FrameDatosAgente extends javax.swing.JFrame {

    TestConnection con = new TestConnection();
    int x,y;
    /**
     * Creates new form FrameDatosAgente
     */
    public FrameDatosAgente() {
        setUndecorated(true);
        initComponents();
        this.ponerfondo("/imagenes/LogoFinal.png");
       // this.jCBSexo.setModel(CargarDatos("select * from informacion_agente", "nombre"));
        this.setLocation(400, 200);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jTFUsuario = new javax.swing.JTextField();
        jTFTelefono = new javax.swing.JTextField();
        jLNombre = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jLBNumero_Doc = new javax.swing.JLabel();
        jTFFecha_Nac = new javax.swing.JTextField();
        jLBFecha_Nac = new javax.swing.JLabel();
        jLApellido = new javax.swing.JLabel();
        jLBSexo = new javax.swing.JLabel();
        jCBTipo_Doc = new javax.swing.JComboBox();
        jLBApellidos = new javax.swing.JLabel();
        jTFNumero_Doc = new javax.swing.JTextField();
        jLBEdad = new javax.swing.JLabel();
        jLBContrasenia = new javax.swing.JLabel();
        jLBTipo_Doc = new javax.swing.JLabel();
        jLEdad = new javax.swing.JLabel();
        jTFApellido = new javax.swing.JTextField();
        jLInstruccion = new javax.swing.JLabel();
        jLBUsuario = new javax.swing.JLabel();
        jLBNombre = new javax.swing.JLabel();
        jLBienvenido = new javax.swing.JLabel();
        jLMasculino = new javax.swing.JLabel();
        jTFNombre = new javax.swing.JTextField();
        jLFecha_Nac = new javax.swing.JLabel();
        jLUsuario = new javax.swing.JLabel();
        jLNumero_Doc = new javax.swing.JLabel();
        jLTipo_Doc = new javax.swing.JLabel();
        jLTelefono = new javax.swing.JLabel();
        jBAtras = new javax.swing.JButton();
        jLContrasenia = new javax.swing.JLabel();
        jPFContraseña = new javax.swing.JPasswordField();
        jCBSexo = new javax.swing.JComboBox();
        jBSalir = new javax.swing.JButton();
        jBFGuardar = new javax.swing.JButton();
        jLBTelefono = new javax.swing.JLabel();
        jTFEdad = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLCargo = new javax.swing.JLabel();
        jCBCargo = new javax.swing.JComboBox();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));
        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder(java.awt.Color.lightGray, java.awt.Color.lightGray));
        jPanel1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jPanel1MousePressed(evt);
            }
        });
        jPanel1.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                jPanel1MouseDragged(evt);
            }
        });

        jLNombre.setText("Nombre");

        jTFFecha_Nac.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTFFecha_NacMouseClicked(evt);
            }
        });

        jLApellido.setText("Apellido");

        jCBTipo_Doc.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "- - -", "R.C", "T.I", "C.C", "C.E", "NIT" }));

        jLEdad.setText("Edad");

        jLInstruccion.setText("Por favor digite la informacion requerida a continuacion.");

        jLBienvenido.setText("BIENVENIDO:");

        jLMasculino.setText("Sexo");

        jLFecha_Nac.setText("Fecha de Nacimiento");

        jLUsuario.setText("Usuario");

        jLNumero_Doc.setText("Numero de Documento");

        jLTipo_Doc.setText("Tipo de Documento");

        jLTelefono.setText("Telefono");

        jBAtras.setText("Atras");
        jBAtras.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jBAtrasMouseClicked(evt);
            }
        });

        jLContrasenia.setText("Contraseña");

        jPFContraseña.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jPFContraseñaActionPerformed(evt);
            }
        });

        jCBSexo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "- - -", "Masculino", "Femenino" }));
        jCBSexo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCBSexoActionPerformed(evt);
            }
        });

        jBSalir.setText("Salir");
        jBSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBSalirActionPerformed(evt);
            }
        });

        jBFGuardar.setText("Guardar");
        jBFGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBFGuardarActionPerformed(evt);
            }
        });

        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/Agente.png"))); // NOI18N

        jLCargo.setText("Cargo");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addComponent(jLNombre)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(jLBNombre, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addComponent(jLUsuario)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jLBUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addComponent(jTFNombre)
                                .addComponent(jTFUsuario, javax.swing.GroupLayout.DEFAULT_SIZE, 198, Short.MAX_VALUE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jCBCargo, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(jLCargo))
                                        .addGap(65, 65, 65))
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jCBTipo_Doc, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addGroup(jPanel1Layout.createSequentialGroup()
                                                .addComponent(jLTipo_Doc)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(jLBTipo_Doc, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                                .addComponent(jTFEdad)
                                                .addGroup(jPanel1Layout.createSequentialGroup()
                                                    .addComponent(jLMasculino)
                                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                    .addComponent(jLBSexo, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                                                .addGroup(jPanel1Layout.createSequentialGroup()
                                                    .addComponent(jLEdad)
                                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                    .addComponent(jLBEdad, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                                                .addComponent(jCBSexo, 0, 198, Short.MAX_VALUE))
                                            .addComponent(jBAtras))
                                        .addGap(0, 0, Short.MAX_VALUE)))
                                .addGap(50, 50, 50)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(jPanel1Layout.createSequentialGroup()
                                            .addComponent(jLNumero_Doc)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(jLBNumero_Doc, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addComponent(jTFNumero_Doc, javax.swing.GroupLayout.PREFERRED_SIZE, 218, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                        .addComponent(jTFTelefono, javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                            .addComponent(jLFecha_Nac)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(jLBFecha_Nac, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                            .addComponent(jLTelefono)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(jLBTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addComponent(jTFFecha_Nac, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 218, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(jPanel1Layout.createSequentialGroup()
                                            .addComponent(jLApellido)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(jLBApellidos, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGroup(jPanel1Layout.createSequentialGroup()
                                            .addComponent(jLContrasenia)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(jLBContrasenia, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addComponent(jTFApellido, javax.swing.GroupLayout.PREFERRED_SIZE, 218, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(jPFContraseña, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 218, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(jBFGuardar)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jBSalir)))))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLBienvenido)
                            .addComponent(jLInstruccion)
                            .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 352, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 37, Short.MAX_VALUE))))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(30, 30, 30)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLBienvenido)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLInstruccion)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLNombre, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLBNombre, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTFNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLBUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTFUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLApellido, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jTFApellido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLContrasenia, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jLBContrasenia, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPFContraseña, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLBApellidos, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLTipo_Doc)
                    .addComponent(jLNumero_Doc)
                    .addComponent(jLBNumero_Doc, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLBTipo_Doc, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jCBTipo_Doc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTFNumero_Doc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLMasculino, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLBSexo, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jCBSexo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLEdad, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLBEdad, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                .addComponent(jLTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(6, 6, 6)))
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTFEdad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jTFTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLFecha_Nac, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLBFecha_Nac, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTFFecha_Nac, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLBTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLCargo)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jCBCargo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 11, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jBSalir)
                        .addComponent(jBFGuardar))
                    .addComponent(jBAtras))
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    public void ponerfondo(String url) {
        this.jPanel1.add(new Fondo(this.getSize(), url));
        repaint();
    }
    private DefaultComboBoxModel CargarDatos(String consulta, String campo) {
        try {
            DefaultComboBoxModel combo = new DefaultComboBoxModel();
            con = new TestConnection();
            try (ResultSet res = con.Consulta(consulta)) {
                while (res.next()) {
                    combo.addElement(res.getObject(campo));
                }
            }
            con.cerrar();
            return combo;
        } catch (SQLException ex) {
            Logger.getLogger(FrameDatosAdministrador.class.getName()).log(Level.SEVERE, null, ex);
            JOptionPane.showMessageDialog(null, ex);
            return null;


        }



    }

    private boolean verificar(JTextField jt) {

        String campo = jt.getText();
        String replaceAll = campo.replaceAll(" +", " ");
        campo = campo.trim();
        if (campo.length() == 0) {
            return false;
        }
        return true;


    }

    private void guardarAlumno(java.awt.event.ActionEvent e) {
        if (this.jTFNombre.getText().equals("") || this.jTFApellido.getText().equals("") || this.jTFUsuario.getText().equals("") || this.jPFContraseña.getText().equals("") || this.jTFNumero_Doc.getText().equals("")
                || this.jTFFecha_Nac.getText().equals("") || this.jTFEdad.getText().equals("") || this.jTFTelefono.getText().equals("")) {
            this.jLabel1.setText("Los campos marcados son obligatorios");
            this.jLabel1.setForeground(new Color(255, 0, 0));

        }
        if (this.jTFNombre.getText().equals("")) {
            this.jLBNombre.setText("*");
            this.jLBNombre.setForeground(new Color(255, 0, 0));
        }
        if (this.jTFApellido.getText().equals("")) {
            this.jLBApellidos.setText("*");
            this.jLBApellidos.setForeground(new Color(255, 0, 0));
        }
        if (this.jTFUsuario.getText().equals("")) {
            this.jLBUsuario.setText("*");
            this.jLBUsuario.setForeground(new Color(255, 0, 0));
        }
        if (this.jPFContraseña.getText().equals("")) {
            this.jLBContrasenia.setText("*");
            this.jLBContrasenia.setForeground(new Color(255, 0, 0));
        }
        if (this.jCBTipo_Doc.getSelectedItem().equals("")) {
            this.jLBTipo_Doc.setText("*");
            this.jLBTipo_Doc.setForeground(new Color(255, 0, 0));
        }
        if (this.jTFNumero_Doc.getText().equals("")) {
            this.jLBNumero_Doc.setText("*");
            this.jLBNumero_Doc.setForeground(new Color(255, 0, 0));
        }
        if (this.jCBSexo.getSelectedItem().equals("")) {
            this.jLBSexo.setText("*");
            this.jLBSexo.setForeground(new Color(255, 0, 0));
        }
        if (this.jTFFecha_Nac.getText().equals("")) {
            this.jLBFecha_Nac.setText("*");
            this.jLBFecha_Nac.setForeground(new Color(255, 0, 0));
        }
        if (this.jTFEdad.getText().equals("")) {
            this.jLBEdad.setText("*");
            this.jLBEdad.setForeground(new Color(255, 0, 0));
        }
        if (this.jTFTelefono.getText().equals("")) {
            this.jLBTelefono.setText("*");
            this.jLBTelefono.setForeground(new Color(255, 0, 0));
        }

    }
    private void jBAtrasMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jBAtrasMouseClicked
        new FrameAdministrador().setVisible(true);
        this.dispose();
    }//GEN-LAST:event_jBAtrasMouseClicked

    private void jPFContraseñaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jPFContraseñaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jPFContraseñaActionPerformed

    private void jCBSexoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCBSexoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jCBSexoActionPerformed

    private void jBSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBSalirActionPerformed
        int a = JOptionPane.showConfirmDialog(null, "¿Esta seguro que desea salir?");
        if (a == 0) {
            System.exit(0);

        }
    }//GEN-LAST:event_jBSalirActionPerformed

    private void jBFGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBFGuardarActionPerformed
        TestConnection con = new TestConnection();
        con.conectar();

        String z = "insert into informacion_agente values ('" + jTFNombre.getText() + "','" + jTFApellido.getText() + "','" + jTFUsuario.getText()
                + "','" + jPFContraseña.getPassword() + "','" + jCBTipo_Doc.getSelectedItem() + "','" + jTFNumero_Doc.getText() + "','" + jCBSexo.getSelectedItem()
                + "','" + jTFFecha_Nac.getText() + "','" + jTFEdad.getText() + "','" + jTFTelefono.getText() + "')";
        try {

            if (verificar(jTFNombre) && verificar(jTFApellido) && verificar(jTFUsuario) && verificar(jPFContraseña)
                    && verificar(jTFNumero_Doc) && verificar(jTFFecha_Nac) && verificar(jTFEdad) && verificar(jTFTelefono)) {
                JOptionPane.showConfirmDialog(this, "¿Esta seguro de ingresar los datos?");
                con.update(z);
                JOptionPane.showMessageDialog(null, "Datos ingresados correctamente");
                new FrameAdministrador().setVisible(true);
                this.dispose();
            } else {
                guardarAlumno(evt);

                JOptionPane.showMessageDialog(this, "Por favor digite todos los campos");
            }

        } catch (SQLException ex) {
            Logger.getLogger(FrameDatosAgente.class.getName()).log(Level.SEVERE, null, ex);
        }
        con.cerrar();
    }//GEN-LAST:event_jBFGuardarActionPerformed

    private void jPanel1MouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jPanel1MouseDragged
        Point point = MouseInfo.getPointerInfo().getLocation();
        setLocation(point.x - x, point.y - y);
    }//GEN-LAST:event_jPanel1MouseDragged

    private void jPanel1MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jPanel1MousePressed
        x = evt.getX();
        y = evt.getY();
    }//GEN-LAST:event_jPanel1MousePressed

    private void jTFFecha_NacMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTFFecha_NacMouseClicked
      this.jTFFecha_Nac.setText(new DatePicker(jTFFecha_Nac).setPickedDate());
    }//GEN-LAST:event_jTFFecha_NacMouseClicked

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(FrameDatosAgente.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(FrameDatosAgente.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(FrameDatosAgente.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(FrameDatosAgente.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new FrameDatosAgente().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jBAtras;
    private javax.swing.JButton jBFGuardar;
    private javax.swing.JButton jBSalir;
    private javax.swing.JComboBox jCBCargo;
    private javax.swing.JComboBox jCBSexo;
    private javax.swing.JComboBox jCBTipo_Doc;
    private javax.swing.JLabel jLApellido;
    private javax.swing.JLabel jLBApellidos;
    private javax.swing.JLabel jLBContrasenia;
    private javax.swing.JLabel jLBEdad;
    private javax.swing.JLabel jLBFecha_Nac;
    private javax.swing.JLabel jLBNombre;
    private javax.swing.JLabel jLBNumero_Doc;
    private javax.swing.JLabel jLBSexo;
    private javax.swing.JLabel jLBTelefono;
    private javax.swing.JLabel jLBTipo_Doc;
    private javax.swing.JLabel jLBUsuario;
    private javax.swing.JLabel jLBienvenido;
    private javax.swing.JLabel jLCargo;
    private javax.swing.JLabel jLContrasenia;
    private javax.swing.JLabel jLEdad;
    private javax.swing.JLabel jLFecha_Nac;
    private javax.swing.JLabel jLInstruccion;
    private javax.swing.JLabel jLMasculino;
    private javax.swing.JLabel jLNombre;
    private javax.swing.JLabel jLNumero_Doc;
    private javax.swing.JLabel jLTelefono;
    private javax.swing.JLabel jLTipo_Doc;
    private javax.swing.JLabel jLUsuario;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPasswordField jPFContraseña;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JTextField jTFApellido;
    private javax.swing.JTextField jTFEdad;
    private javax.swing.JTextField jTFFecha_Nac;
    private javax.swing.JTextField jTFNombre;
    private javax.swing.JTextField jTFNumero_Doc;
    private javax.swing.JTextField jTFTelefono;
    private javax.swing.JTextField jTFUsuario;
    // End of variables declaration//GEN-END:variables
}
